﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using System.Data;
using System.ComponentModel;
using System.Reflection;
using System.Net;
using System.Security;
using Microsoft.Exchange.WebServices.Data;
using Microsoft.Exchange.WebServices.Auth;
using Microsoft.Exchange.WebServices;
using System.IO;
using System.Text;
using System.Net.Mail;
using System.Net.Mime;
using System.Xml;
using System.Web.Configuration;
using VBModel;
using VBBLL;

namespace VenueManage
{
    /// WebService1 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消注释以下行。 
    [System.Web.Script.Services.ScriptService]
    public class Booking_chooseTime : System.Web.Services.WebService
    {
        [WebMethod(EnableSession = true)]
        public string getInstance()
        {
            try
            {
                string conn = WebConfigurationManager.ConnectionStrings["meetingroomManagementConnectionString"].ConnectionString;// "Data Source=mesdbsrv.gwkf.cn;Initial Catalog=VenueBooking;User ID=vbuser;Password=vb_2013";
                string sqlStr = "select * from [VenueBooking].[dbo].[MTR_instance]";
                return VBBLL.Worker.GetDataSet(sqlStr, conn).Tables[0].Rows[0][0].ToString();
            }
            catch (Exception ex)
            {
                VBBLL.Worker.writeErrorMessage("0", ex, Session["userName"].ToString());
                return "";
            }
        }

        [WebMethod(EnableSession = true)]
        public string updateInstanceByAdmin(string newInstance)
        {
            try
            {
                string conn = WebConfigurationManager.ConnectionStrings["meetingroomManagementConnectionString"].ConnectionString;// "Data Source=mesdbsrv.gwkf.cn;Initial Catalog=VenueBooking;User ID=vbuser;Password=vb_2013";
                string sqlStr = "delete from [VenueBooking].[dbo].[MTR_instance]";
                VBBLL.Worker.doSql(sqlStr, conn);
                string sqlInsert = string.Format(@"insert into [VenueBooking].[dbo].[MTR_instance] values ('{0}')", newInstance);
                VBBLL.Worker.doSql(sqlInsert, conn);
                return "更新成功";
            }
            catch (Exception ex)
            {
                VBBLL.Worker.writeErrorMessage("0", ex, Session["userName"].ToString());
                return ex.Message;
            }
        }

        [WebMethod(EnableSession = true)]
        public List<String> Init()
        {
            List<String> tlist = new List<String>();
            var cls = new BaseRepositoryBLL<MTR_bas_Type>().LoadEntities(p => p.available).Distinct();
            foreach (var t in cls)
            {
                tlist.Add(t.ToString());
            }
            return tlist;
        }

        [WebMethod(EnableSession = true)]
        public string layout()
        {
            Session["userName"] = null;
            Session["userInfo"] = null;
            return "退出成功";
        }

        [WebMethod(EnableSession = true)]
        public string[] getEmails()
        {
            if (Application["EmailAddress"] == null)
            {
                Application["EmailAddress"] = Worker.getEmailAddress();
            }
            List<String> EmailList = (List<String>)Application["EmailAddress"];
            string[] eList = new string[EmailList.Count];
            for (int i = 0; i < EmailList.Count; i++)
            {
                eList[i] = EmailList[i];
            }
            return eList;
        }

        [WebMethod(EnableSession = true)]
        public string[] getNameAndEmails()
        {
            if (Application["NameAndEmails"] == null)
            {
                Application["NameAndEmails"] = Worker.getNameAndEmail();
            }
            string[] NameAndEmailList = (string[])Application["NameAndEmails"];
            return NameAndEmailList;
        }

        [WebMethod(EnableSession = true)]
        public List<string> checkEmail(string startString)
        {
            if (Application["EmailAddress"] == null)
            {
                Application["EmailAddress"] = Worker.getEmailAddress();
            }
            List<String> EmailList = (List<String>)Application["EmailAddress"];

            List<string> lstTmp = new List<string>();
            ((List<String>)Application["EmailAddress"]).Select(p => p.ToString()).ToList().ForEach(q =>
            {
                if (q.StartsWith(startString))
                    lstTmp.Add(q);
            });
            return lstTmp;
        }

        [WebMethod(EnableSession = true)]
        public string Lock(int meetingRoomNo, string startDate, string startTime, string endDate, string endTime, string weeks)
        {
            //锁定一次
            if (weeks.Length <= 1)
            {
                return OnetimeLock(meetingRoomNo, startDate, startTime, endDate, endTime);
            }
            //周期锁定
            else
            {
                return PeriodicLock(meetingRoomNo, startDate, startTime, endDate, endTime, weeks);
            }
        }


        [WebMethod(EnableSession = true)]
        public string Booking(string participants, string btnId, string meetingTheme, string bookingVIP, string meetingAbstract, string phoneNo,
            string cc,
            int meetingRoomNo, string mtrName, string specialRequestFirst, string specialRequestSecond,
            string startDate, string startTime, string endDate, string endTime, string userName, string weeks, string passWord)
        {
            try
            {
                string results = "";

                DateTime st = DateTime.Parse(startDate + " " + startTime);  //会议开始时间
                DateTime et = DateTime.Parse(endDate + " " + endTime);      //会议结束时间
                DateTime timeNow = DateTime.Now;

                if (st < timeNow)
                {
                    return "您预定的时间早于当前时间，请重新选择活动开始时间";
                }
                string conn = WebConfigurationManager.ConnectionStrings["meetingroomManagementConnectionString"].ConnectionString;
                string getVIPByID = "select mtrType, mtrAddress + mtrAddress1 +' '+ mtrName from  [VenueBooking].[dbo].[MTR_bas_Meetingroom] where mtrId = " + meetingRoomNo;
                DataTable dt = Worker.GetDataSet(getVIPByID, conn).Tables[0];
                bookingVIP = dt.Rows[0][0].ToString();
                string mtrAdd = dt.Rows[0][1].ToString();
                //本次是单次预定
                if (weeks.Length < 1)
                {
                    if (startDate != endDate)
                    {
                        return "您的选择跨天，请重新选择或联系管理员周期预定";
                    }
                    if (checkConflict(meetingRoomNo, startDate, startTime, endDate, endTime) != "")
                    {
                        return checkConflict(meetingRoomNo, startDate, startTime, endDate, endTime);
                    }
                    //和周期冲突检测
                    else
                    {
                        if (checkOnceWithPeriodicConflict(meetingRoomNo, startDate, startTime, endDate, endTime) != "")
                        {
                            return checkOnceWithPeriodicConflict(meetingRoomNo, startDate, startTime, endDate, endTime);
                        }
                    }
                }
                //本次是周期性预定
                if (weeks.Length > 1)
                {

                    if (checkPeriodicConflict(meetingRoomNo, startDate, startTime, weeks, endDate, endTime) != "")
                    {
                        return checkPeriodicConflict(meetingRoomNo, startDate, startTime, weeks, endDate, endTime);
                    }
                }
                if (btnId == "lock")
                {
                    results = Lock(meetingRoomNo, startDate, startTime, endDate, endTime, weeks);
                    return results;
                }
                else
                {
                    int OncelongestHour = 0; //每次最多订多长时间
                    int LongestAdvanceBookingDay = 0;//最多提前多久订
                    int mtrNo = meetingRoomNo;
                    TimeSpan ts1 = new TimeSpan(st.Ticks);
                    TimeSpan ts2 = new TimeSpan(et.Ticks);
                    string dateDiff = null;
                    TimeSpan ts = ts1.Subtract(ts2).Duration();
                    //显示时间  
                    dateDiff = ts.Days.ToString() + "天"
                            + ts.Hours.ToString() + "小时"
                            + ts.Minutes.ToString() + "分钟"
                            + ts.Seconds.ToString() + "秒";
                    TimeSpan ts3 = new TimeSpan(timeNow.Ticks);

                    TimeSpan tsn = ts3.Subtract(ts2).Duration();//提前预定的天数

                    string dateDiff1 = tsn.Days.ToString() + "天"
                            + tsn.Hours.ToString() + "小时"
                            + tsn.Minutes.ToString() + "分钟"
                            + tsn.Seconds.ToString() + "秒";

                    //查询会议室对应的会议室资源
                    var cls = new BaseRepositoryBLL<MTR_bas_Meetingroom>().LoadEntities(p => p.mtrId.Equals(mtrNo)).FirstOrDefault();
                    //(from c in mtrmEntities.MTR_bas_Meetingroom
                    //       where c.mtrId == mtrNo
                    //       select c).SingleOrDefault<MTR_bas_Meetingroom>();
                    OncelongestHour = Convert.ToInt32(cls.mtrLongestBookingDay);
                    LongestAdvanceBookingDay = Convert.ToInt32(cls.mtrLongestAdvanceBookingTime);
                    //周期预定
                    if (weeks.Length > 1)
                    {
                        results = PeriodicBookingSuccess(participants, cc, meetingTheme, meetingAbstract, phoneNo, mtrAdd, mtrNo, specialRequestFirst,
                         specialRequestSecond, st, et, startDate, startTime, endDate, endTime, userName, weeks, passWord);
                    }
                    //开启审批流程
                    else if (st.DayOfWeek.ToString() == "Saturday" || st.DayOfWeek.ToString() == "Sunday" || ts.Hours >= OncelongestHour
                        || (tsn.Days >= LongestAdvanceBookingDay) || bookingVIP == "VIP")
                    {
                        //存入数据库
                        results = ApproveBooking(participants, cc, meetingTheme, meetingAbstract, phoneNo, mtrAdd, mtrNo, specialRequestFirst,
                        specialRequestSecond, st, et, startDate, startTime, endDate, endTime, userName, weeks);
                    }
                    //满足自助预定条件 && weeks.Length <= 1 
                    else if ((LongestAdvanceBookingDay > tsn.Days && ts.Hours < OncelongestHour && bookingVIP == "普通"))//
                    {
                        results = SelfBookingSuccess(participants, cc, meetingTheme, meetingAbstract, phoneNo, mtrAdd, mtrNo, specialRequestFirst,
                         specialRequestSecond, st, et, startDate, startTime, endDate, endTime, userName, weeks);
                    }
                    return results;
                }
            }
            catch (Exception ex)
            {
                Worker.writeErrorMessage("0", ex, "booking");
                return ex.Message.ToString();
            }
        }



        /// <summary>
        /// 开启审批流程
        /// </summary>
        /// <param name="participants">与会人</param>
        /// <param name="meetingTheme">主题</param>
        /// <param name="meetingAbstract">简介</param>
        /// <param name="mtrAdd">地址</param>
        /// <param name="mtrNo">编号</param>
        /// <param name="specialRequestFirst">特殊要求一</param>
        /// <param name="specialRequestSecond">特殊要求二</param>
        /// <param name="st"></param>
        /// <param name="et"></param>
        /// <param name="startDate">开始日期</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endDate">结束日期</param>
        /// <param name="endTime">结束时间</param>
        /// <param name="weeks">星期</param>
        /// <returns></returns>
        public string ApproveBooking(string participants, string cc, string meetingTheme,
            string meetingAbstract, string phoneNo, string mtrAdd, int mtrNo, string specialRequestFirst,
                string specialRequestSecond, DateTime st, DateTime et, string startDate,
            string startTime, string endDate, string endTime, string userName, string weeks)
        {
            string orgType1 = Session["orgType1"].ToString();
            string orgType3 = Session["orgType3"].ToString();

            ApproveBll b = new ApproveBll();
            return b.ApproveBooking(participants, cc, meetingTheme,
             meetingAbstract, phoneNo, mtrAdd, mtrNo, specialRequestFirst,
                 specialRequestSecond, st, et, startDate,
             startTime, endDate, endTime, userName, weeks, orgType1, orgType3);

        }

        /// <summary>
        /// 单次冲突检测(单次，周期)
        /// </summary>
        /// <param name="meetingRoomNo"></param>
        /// <param name="startDate"></param>
        /// <param name="startTime"></param>
        /// <param name="endDate"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        public string checkConflict(int meetingRoomNo, string startDate, string startTime, string endDate, string endTime)
        {
            try
            {
                DateTime sd = DateTime.Parse(startDate);
                DateTime st = DateTime.Parse(startDate + " " + startTime);   //会议开始时间
                DateTime et = DateTime.Parse(endDate + " " + endTime);       //会议结束时间
                using (var mme = new VenueBookingTestEntities())
                {
                    var query = (from bm in mme.MTR_bas_BookingManage
                                 join bs in mme.MTR_bas_BookingSchedul
                                     on bm.bookingID equals bs.planId
                                 where bm.Meetingroom == meetingRoomNo && bs.isPeriodic == false
                                 && bs.meetingStartDate >= sd && (bm.bookingState == 1 || bm.bookingState == 2 || bm.bookingState == 3)
                                 select new
                                 {
                                     ssd = bs.meetingStartDate,
                                     sst = bs.startTime,
                                     sed = bs.meetingEndDate,
                                     set = bs.endTime,
                                 }).ToList();
                    foreach (var q in query)
                    {
                        DateTime mst = DateTime.Parse(q.ssd.Value.ToLongDateString() + " " + q.sst);
                        DateTime met = DateTime.Parse(q.sed.Value.ToLongDateString() + " " + q.set);
                        if (mst < et && mst > st)
                        {
                            return "系统检测到与已存在的预定发生冲突";
                        }
                        if (st < met && et >= met)
                        {
                            return "系统检测到与已存在的预定发生冲突";
                        }
                        if (mst <= st && et <= met)
                        {
                            return "系统检测到与已存在的预定发生冲突";
                        }
                        if (mst > st && et > met)
                        {
                            return "系统检测到与已存在的预定发生冲突";
                        }
                    }
                }
                return "";
            }
            catch (Exception ex)
            {
                Worker.writeErrorMessage("0", ex, "checkConflict");
                return ex.Message;
            }
        }
        /// <summary>
        /// 条件满足，完成自助预定
        /// </summary>
        /// <param name="participants"></param>
        /// <param name="meetingTheme"></param>
        /// <param name="meetingAbstract"></param>
        /// <param name="mtrAdd"></param>
        /// <param name="mtrNo"></param>
        /// <param name="specialRequestFirst"></param>
        /// <param name="specialRequestSecond"></param>
        /// <param name="st"></param>
        /// <param name="et"></param>
        /// <param name="startDate"></param>
        /// <param name="startTime"></param>
        /// <param name="endDate"></param>
        /// <param name="endTime"></param>
        /// <param name="weeks"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        public string SelfBookingSuccess(string participants, string cc, string meetingTheme, string meetingAbstract, string phoneNo,
            string mtrAdd, int mtrNo, string specialRequestFirst, string specialRequestSecond, DateTime st, DateTime et,
            string startDate, string startTime, string endDate, string endTime, string userName, string weeks)
        {
            try
            {
                string orgType1 = Session["orgType1"].ToString();
                string orgType3 = Session["orgType3"].ToString();
                BookBll b = new BookBll();
                return b.SelfBookingSuccess(participants, cc, meetingTheme, meetingAbstract, phoneNo,
                mtrAdd, mtrNo, specialRequestFirst, specialRequestSecond, st, et,
                startDate, startTime, endDate, endTime, userName, weeks, orgType1, orgType3);
            }
            catch (Exception e)
            {
                return e.Message;
            }
        }
        [WebMethod(EnableSession = true)]
        private string OnetimeLock(int meetingRoomNo, string startDate, string startTime, string endDate, string endTime)
        {
            try
            {
                string userName = Session["userName"].ToString();
                string orgType1 = Session["orgType1"].ToString();
                string orgType3 = Session["orgType3"].ToString();
                BookBll b = new BookBll();
                return b.OnetimeLock(meetingRoomNo, startDate, startTime, endDate, endTime, userName, orgType1, orgType3);
            }
            catch (Exception ex)
            {
                Worker.writeErrorMessage("0", ex, Session["userName"].ToString());
                return ex.Message;
            }
        }

        string error;
        [WebMethod]
        private bool checkAD(string adPath, string domainName, string AD_AccountNo, string AD_Password)
        {
            LdapAuthentication adAuth = new LdapAuthentication(adPath);
            //自己寫的類別檔。
            try
            {
                return adAuth.IsAuthenticated(domainName, AD_AccountNo, AD_Password);
            }
            catch (Exception ex)
            {
                Worker.writeErrorMessage("0", ex, Session["userName"].ToString());
                error = ex.Message;
                return false;
            }
        }

        public string CheckUser(string userName, string pwd)
        {
            string AD_AccountNo = userName;
            string AD_Password = pwd;
            //在这里校验AD用户及密码
            string domainName = "GWKF";
            string adPath = "LDAP://" + domainName;

            if (checkAD(adPath, domainName, AD_AccountNo, AD_Password))
            {
                return "Succsee";
            }
            else return error;
            //return "xxx";
        }

        /// <summary>
        /// 周期性预定
        /// </summary>
        /// <param name="participants"></param>
        /// <param name="meetingTheme"></param>
        /// <param name="meetingAbstract"></param>
        /// <param name="mtrAdd"></param>
        /// <param name="mtrNo"></param>
        /// <param name="specialRequestFirst"></param>
        /// <param name="specialRequestSecond"></param>
        /// <param name="st"></param>
        /// <param name="et"></param>
        /// <param name="startDate"></param>
        /// <param name="startTime"></param>
        /// <param name="endDate"></param>
        /// <param name="endTime"></param>
        /// <param name="weeks"></param>
        /// <returns></returns>
        [WebMethod(EnableSession = true)]
        public string PeriodicBookingSuccess(string participants, string cc, string meetingTheme, string meetingAbstract, string phoneNo, string mtrAdd, int mtrNo, string specialRequestFirst,
              string specialRequestSecond, DateTime st, DateTime et, string startDate, string startTime, string endDate, string endTime, string userName, string weeks, string passWord)
        {
            BookBll b = new BookBll();
            string user = Session["userName"].ToString();
            string orgType1 = Session["orgType1"].ToString();
            string orgType3 = Session["orgType3"].ToString();

            if (CheckUser(userName, passWord) != "Succsee")
            {
                return "您输入在密码错误";
            }

            string otp = new BookBll().checkOnceConflict(mtrNo, startDate, startTime, weeks, endDate, endTime);
            string ptp = new BookBll().checkPeriodicConflict(mtrNo, startDate, startTime, weeks, endDate, endTime);
            if (otp.Length > 1 || ptp.Length > 1) return otp + ptp;

            MTR_bas_BookingManage mtrBM = new MTR_bas_BookingManage();
            MTR_bas_BookingSchedul mtrBS = new MTR_bas_BookingSchedul();
            string keyId = Guid.NewGuid().ToString();
            string[] weekdays = weeks.Split(',');

            string[] wek = new string[weekdays.Length - 1];

            for (int k = 0; k < weekdays.Length - 1; k++)
            {
                wek[k] = weekdays[k];
            }
            mtrBS.isPeriodic = true;
            mtrBM.bookingID = keyId;
            mtrBM.bookingType = "管理员预定";
            mtrBM.Meetingroom = mtrNo;
            mtrBM.bookingPerson = Session["userName"].ToString();
            mtrBM.bookingTime = DateTime.Now;  //保存预定时间
            mtrBM.meetingTheme = meetingTheme;
            mtrBM.participants = participants;
            mtrBM.meetingAbstract = meetingAbstract;
            mtrBM.specialRequestFirst = specialRequestFirst;
            mtrBM.specialRequestSecond = specialRequestSecond;
            mtrBM.bookingState = 2;//状态为预定成功
            mtrBM.undefine1 = Session["orgType1"].ToString();
            mtrBM.undefine2 = Session["orgType3"].ToString();
            mtrBM.useResult = 0;

            new BaseRepositoryBLL<MTR_bas_BookingManage>().AddEntities(mtrBM);

            mtrBS.Monday = false;
            mtrBS.Tuesday = false;
            mtrBS.Wednesday = false;
            mtrBS.Thursday = false;
            mtrBS.Friday = false;
            mtrBS.Saturday = false;
            mtrBS.Sunday = false;
            foreach (string weekday in weekdays)
            {
                if (weekday == "Monday") mtrBS.Monday = true;
                else if (weekday == "Tuesday") mtrBS.Tuesday = true;
                else if (weekday == "Wednesday") mtrBS.Wednesday = true;
                else if (weekday == "Thursday") mtrBS.Thursday = true;
                else if (weekday == "Friday") mtrBS.Friday = true;
                else if (weekday == "Saturday") mtrBS.Saturday = true;
                else if (weekday == "Sunday") mtrBS.Sunday = true;
            }
            mtrBS.planId = keyId;
            mtrBS.meetingRoom = mtrNo;
            mtrBS.meetingStartDate = Convert.ToDateTime(startDate);
            mtrBS.startTime = startTime;
            mtrBS.meetingEndDate = Convert.ToDateTime(endDate);
            mtrBS.endTime = endTime;
            mtrBS.undefine1 = new BookBll().timeDiffer((startDate + " " + mtrBS.startTime), (endDate + " " + mtrBS.endTime));
            mtrBS.undefine2 = phoneNo;
            mtrBS.undefine3 = cc;

            new BaseRepositoryBLL<MTR_bas_BookingSchedul>().AddEntities(mtrBS);
            try
            {
                //发送邮件
                emailSrv e = new emailSrv();
                e.sendPeriodicMeetingMessage(keyId, userName, participants, cc, meetingTheme, meetingAbstract, mtrAdd, mtrNo, specialRequestFirst,
              specialRequestSecond, st, et, startDate, startTime, endDate, endTime, wek, passWord);
            }
            catch (Exception ex)
            {
                Worker.writeErrorMessage("0", ex, Session["userName"].ToString());
                return ex.Message;
            }
            return "恭喜您，周期预定成功";
        }


        [WebMethod(EnableSession = true)]
        private string PeriodicLock(int meetingRoomNo, string startDate, string startTime, string endDate, string endTime, string weeks)
        {
            try
            {
                BookBll b = new BookBll();
                string bookPerson = Session["userName"].ToString();
                string orgType1 = Session["orgType1"].ToString();
                string orgType3 = Session["orgType3"].ToString();
                return b.PeriodicLock(meetingRoomNo, startDate, startTime, endDate, endTime, weeks, bookPerson, orgType1, orgType3);
            }
            catch (Exception ex)
            {
                Worker.writeErrorMessage("0", ex, Session["userName"].ToString());
                return ex.Message;
            }
        }

        //public void testMeeting()
        //{
        //    //#region 发送邮件代码
        //    try
        //    {
        //        ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
        //        service.TraceEnabled = true;
        //        service.Credentials = new NetworkCredential("mespublisher", "mes_2011", "kaifa.cn");
        //        service.Url = new Uri(@"https://mail.kaifa.cn/ews/exchange.asmx");
        //        service.UseDefaultCredentials = true;

        //        //service.AutodiscoverUrl("shengweihu@kaifa.cn");//程序可以自动获取到与服务器通信的设置方式
        //        Appointment appointment = new Appointment(service);
        //        appointment.Subject = "test exchange meeting";
        //        appointment.Body = "Let's play tennis for an hour every Saturday at 15:30";
        //        appointment.Start = new DateTime(2013, 10, 16, 15, 30, 00);
        //        appointment.End = appointment.Start.AddHours(1);
        //        appointment.Location = "7#";

        //        appointment.RequiredAttendees.Add("zhengguangyan@kaifa.cn");
        //        appointment.RequiredAttendees.Add("shengweihu@kaifa.cn");

        //        appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);
        //    }
        //    catch (Exception ex)
        //    {
        //        Worker.writeErrorMessage("0", ex, Session["userName"].ToString());
        //    }
        //}

        public void createmeeting()
        {
            emailSrv w = new emailSrv();
            w.SendMeetingRequest(DateTime.Now, DateTime.Now.AddHours(1), "7#", "test meeting", "test desc",
                new string[] { "shengweihu@kaifa.cn", "qifanjian@kaifa.cn", "zhengguangyan@kaifa.cn" }, new string[0], "abc", false, "zhengguangyan", "zhengguangyan@kaifa.cn", true, "");
        }

        private string checkOnceConflict(int mtrNo, string startDate, string startTime, string weeks, string endDate, string endTime)
        {
            BookBll b = new BookBll();
            return b.checkOnceConflict(mtrNo, startDate, startTime, weeks, endDate, endTime);
        }

        protected string checkOnceWithPeriodicConflict(int meetingRoomNo, string startDate, string startTime, string endDate, string endTime)
        {
            BookBll b = new BookBll();
            return b.checkOnceWithPeriodicConflict(meetingRoomNo, startDate, startTime, endDate, endTime);
        }

        //检验周期性预定的冲突
        private string checkPeriodicConflict(int meetingRoomNo, string startDate, string startTime,
            string weekday, string endDate, string endTime)
        {
            BookBll b = new BookBll();
            return b.checkPeriodicConflict(meetingRoomNo, startDate, startTime, weekday, endDate, endTime);
        }

        [WebMethod(EnableSession = true)]
        public List<MtrData> Seek(DateTime date, string type, string address,
            string isVIP, string userName, string orgType1, string orgType3, string capacity)
        {
            BookBll b = new BookBll();
            return b.Seek(date, type, address, isVIP, userName, orgType1, orgType3, capacity);
        }
    }


}
